package net.hn.hnms.biz.plan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.hn.hnms.biz.plan.domain.DimDrivageFace;
import net.hn.hnms.biz.plan.vo.DimDrivageFaceVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DimDrivageFaceMapper extends BaseMapper<DimDrivageFace> {


    @Select("<script>" +
            " select " +
            " case when count(drivage_face_id)>0 then count(drivage_face_id)   else null end  as  totalDimDrivageFace," +
            " sum(drivage_face_length) as totalDrivageFaceLength," +
            " sum(drivage_face_slope) as totalDrivageFaceSlope," +
            " sum(drivage_face_amount) as totalDrivageFaceAmount" +
            " from dim_drivage_face where del_flag='0' and mine_code= #{mineCode} " +
            "</script>")
    DimDrivageFaceVO selectDimMiningFaceTotalByMineCode(@Param("mineCode") String mineCode);

    @Select("<script>" +
            " select " +
            " case when count(drivage_face_id)>0 then count(drivage_face_id)   else null end  as  totalDimDrivageFace," +
            " sum(drivage_face_length) as totalDrivageFaceLength," +
            " sum(drivage_face_slope) as totalDrivageFaceSlope," +
            " sum(drivage_face_amount) as totalDrivageFaceAmount" +
            " from dim_drivage_face where del_flag='0' and company_code= #{mineCode} " +
            "</script>")
    DimDrivageFaceVO selectDimDrivageFaceTotalByCompanyCodeOrName(@Param("mineCode") String mineCode);

    @Select("<script>" +
            "  select " +
            " drivage_face_id ," +
            " drivage_face_length , " +
            " drivage_face_slope, " +
            " drivage_face_direction, " +
            " drivage_face_name, " +
            " status, " +
            " mine_code  " +
            " from dim_drivage_face where del_flag='0' and mine_code= #{mineCode} and status='0' " +
            "</script>")
    Page<DimDrivageFaceVO> selectDimDrivageFaceByMineCode(Page<Object> build,@Param("mineCode") String mineCode);

    @Select("<script>SELECT\n" +
            "\tdrivage_face_id as drivageFaceId, \n" +
            "\tmine_code as mineCode, \n" +
            "\tdrivage_tunnel_code as drivageTunnelCode, \n" +
            "\tdrivage_face_name as drivageFaceName, \n" +
            "\tdrivage_face_code as drivageFaceCode\n" +
            "FROM\n" +
            "\tdim_drivage_face\n" +
            "where \n" +
            "  drivage_face_name=#{drivageName} and  del_flag='0' and mine_code= #{mineCode}  " +
            "</script>")
    List<DimDrivageFaceVO> getDrivageByMineCodeAndDrivageName(@Param("mineCode") String mineCode,@Param("drivageName") String drivageName);
}
